<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>条件渲染</title>
    <script src="./js/babel.min.js"></script>
    <script src="./js/react.development.js"></script>
    <script src="./js/react-dom.development.js"></script>
    <style>
      .ad{
        width: 100%;
        background: rgb(42, 50, 141);
        color: white;
        padding: 30px;
      }
    </style>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">
      //声明变量
      let isVip = false;

      // 创建虚拟 DOM 对象
      //1. if...else
      // let vdom;
      // if(!isVip){
      //   vdom = <div className="ad">我是广告哦~~</div>
      // }
      // 渲染
      // ReactDOM.render(vdom, document.querySelector('#root'));

      //2. 三元运算符  三目运算符
      // ReactDOM.render(<div>
      //   {isVip ? null : <div className="ad">我是广告哦~~</div>}
      //   </div>, document.querySelector('#root'));

      //3. 逻辑与  &&    1 && 2   0 || 2     false && div  = false
      ReactDOM.render(<div>
        {!isVip && <div className="ad">我是广告哦~~</div>}
        </div>, document.querySelector('#root'));

      

    </script>
  </body>
</html>
